package top.hjcwzx.wrench.design.framework.service.tree.node;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import top.hjcwzx.wrench.design.framework.model.tree.TreeReq;
import top.hjcwzx.wrench.design.framework.model.tree.TreeRes;
import top.hjcwzx.wrench.design.framework.service.tree.AbstractTestSupport;
import top.hjcwzx.wrench.design.framework.service.tree.factory.DefaultTreeTestFactory;
import top.hjcwzx.wrench.design.framework.tree.StrategyHandler;


@Slf4j
@Service
@RequiredArgsConstructor
public class RootNode extends AbstractTestSupport<TreeReq, DefaultTreeTestFactory.DynamicContext, TreeRes> {

    private final SwitchNode switchNode;

    @Override
    public TreeRes apply(TreeReq requestParameter, DefaultTreeTestFactory.DynamicContext dynamicContext) throws Exception {
        log.info("抽象规则决策树-根节点执行逻辑");
        return router(requestParameter, dynamicContext);
    }

    @Override
    public StrategyHandler<TreeReq, DefaultTreeTestFactory.DynamicContext, TreeRes> get(TreeReq requestParameter, DefaultTreeTestFactory.DynamicContext dynamicContext) throws Exception {
        log.info("抽象规则决策树-根节点流转-下一节点-开关节点:{}", switchNode);
        return switchNode;
    }
}
